#version 300 es
in vec2 texCoord;
out vec4 FragColor;

uniform sampler2D yTexture;
uniform sampler2D uTexture;
uniform sampler2D vTexture;

void main() {
  // 采样YUV分量
  float y = texture(yTexture, texCoord).r;
  float u = texture(uTexture, texCoord).r - 0.5;
  float v = texture(vTexture, texCoord).r - 0.5;
  float r = y + 1.402 * v;
  float g = y - 0.344 * u - 0.714 * v;
  float b = y + 1.772 * u;
  FragColor = vec4(r, g, b, 1.0);
}
